﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="ehmaManusegaValjund", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(EhmaManusegaValjund))]
    public class EhmaManusegaValjundSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IEhmaManusegaValjund clazz;
        
        public EhmaManusegaValjundSerializer(IEhmaManusegaValjund clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("suurus");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "nonNegativeInteger");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdNonNegativeInteger(((decimal)(clazz.Suurus))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("manuseid");
            if (clazz.Manuseid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "base64Binary");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBase64Binary(((byte[])(clazz.Manuseid))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="suurus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>ehmaManusegaValjund>suurus");
                }
                clazz.Suurus = new global::Xtee.Core.Schema.XsdNonNegativeInteger(Reader.ReadElementString("suurus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ehmaManusegaValjund>suurus", Reader.LocalName);
            }
            if (Reader.LocalName=="manuseid") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Manuseid = new global::Xtee.Core.Schema.XsdBase64Binary(Reader.ReadElementString("manuseid")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>ehmaManusegaValjund>manuseid", Reader.LocalName);
            }
        }
    }
}
